package net.lab1024.sa.admin.module.business.projectLists.controller;

import net.lab1024.sa.admin.module.business.projectLists.domain.form.ProjectListsAddForm;
import net.lab1024.sa.admin.module.business.projectLists.domain.form.ProjectListsQueryForm;
import net.lab1024.sa.admin.module.business.projectLists.domain.form.ProjectListsUpdateForm;
import net.lab1024.sa.admin.module.business.projectLists.domain.vo.ProjectListsVO;
import net.lab1024.sa.admin.module.business.projectLists.service.ProjectListsService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 企业列表 Controller
 *
 * @Author 1
 * @Date 2025-06-30 10:10:25
 * @Copyright 1
 */

@RestController
@Tag(name = "企业列表")
public class ProjectListsController {

    @Resource
    private ProjectListsService projectListsService;

    @Operation(summary = "分页查询 @author 1")
    @PostMapping("/projectLists/queryPage")
    @SaCheckPermission("projectLists:query")
    public ResponseDTO<PageResult<ProjectListsVO>> queryPage(@RequestBody @Valid ProjectListsQueryForm queryForm) {
        return ResponseDTO.ok(projectListsService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 1")
    @PostMapping("/projectLists/add")
    @SaCheckPermission("projectLists:add")
    public ResponseDTO<String> add(@RequestBody @Valid ProjectListsAddForm addForm) {
        return projectListsService.add(addForm);
    }

    @Operation(summary = "更新 @author 1")
    @PostMapping("/projectLists/update")
    @SaCheckPermission("projectLists:update")
    public ResponseDTO<String> update(@RequestBody @Valid ProjectListsUpdateForm updateForm) {
        return projectListsService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 1")
    @PostMapping("/projectLists/batchDelete")
    @SaCheckPermission("projectLists:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return projectListsService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 1")
    @GetMapping("/projectLists/delete/{id}")
    @SaCheckPermission("projectLists:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return projectListsService.delete(id);
    }

    @GetMapping("/projectLists/getByUuid")
    public ResponseDTO<ProjectListsVO> getByUuid(@RequestParam String uuid) {
        return projectListsService.getByUuid(uuid);
    }
}
